/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * viewStock_in_addOrder.java
 *
 * Created on Oct 31, 2011, 4:48:46 PM
 */

package giormi;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author Ling
 */
public class viewStock_in_addOrder extends javax.swing.JFrame {

    private Connection conn;
    private String SQLStatement;
    private String URL;
    private Statement stmt;
    private ResultSet rset;

    /** Creates new form viewStock_in_addOrder */
    private addOrder addorder;
    private int ids=0;
    private int idp=0;

    public viewStock_in_addOrder(addOrder ao, int ids, int idp) {
        initComponents();
        this.setLocation(400, 150);
        this.setSize(400, 480);
        this.setResizable(false);
        this.setDefaultCloseOperation(javax.swing.JFrame.DO_NOTHING_ON_CLOSE);
        addorder = ao;

        connect();
        try {
            SQLStatement = "SELECT s_balance, s_datereceived, s_rrnum, s_quedan, "
                    + "s_expdate, s_proddate, s_lotnum, s_notes, p_packing, p_name, idstock "
                    + "FROM product, stock "
                    + "WHERE idstock = "+ids+" AND idproduct="+idp;
            rset = stmt.executeQuery(SQLStatement);
            while (rset.next()) {
                        vs_RRnumLabel.setText(rset.getString("s_rrnum"));
                        vs_balanceLabel.setText(rset.getString("s_balance"));
                        vs_expdateLabel.setText(rset.getString("s_expdate"));
                        vs_lotnumLabel.setText(rset.getString("s_lotnum"));
                        vs_notesLabel.setText(rset.getString("s_notes"));
                        vs_packingLabel.setText(rset.getString("p_packing"));
                        vs_proddateLabel.setText(rset.getString("s_proddate"));
                        vs_productnameLabel.setText(rset.getString("p_name"));
                        vs_quedanLabel.setText(rset.getString("s_quedan"));
                        vs_receivingdateLabel.setText(rset.getString("s_datereceived"));
                        vs_stocknumLabel.setText(rset.getString("idstock"));
            }
            rset.close();
            disconnect();
        } catch (SQLException ex) {
            Logger.getLogger(searchproductname_in_addstockorder.class.getName()).log(Level.SEVERE, null, ex);
        }


    }

    public void connect(){
        try{
            DBConnection db = new DBConnection();
            conn = DBConnection.get();
            stmt = conn.createStatement();
        }
        catch(Exception e){
            System.out.println(e.getMessage());
            JOptionPane.showMessageDialog(null,e.getMessage(),"ERROR", JOptionPane.WARNING_MESSAGE);
        }
    }

    public void disconnect(){
        try{
            stmt.close();
            conn.close();
        }
        catch(Exception ex){
            System.out.println(ex.getMessage());
            JOptionPane.showMessageDialog(null,ex.getMessage(),"ERROR", JOptionPane.WARNING_MESSAGE);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        vs_productnameLabel = new javax.swing.JLabel();
        vs_packingLabel = new javax.swing.JLabel();
        vs_receivingdateLabel = new javax.swing.JLabel();
        vs_balanceLabel = new javax.swing.JLabel();
        vs_RRnumLabel = new javax.swing.JLabel();
        vs_quedanLabel = new javax.swing.JLabel();
        vs_proddateLabel = new javax.swing.JLabel();
        vs_expdateLabel = new javax.swing.JLabel();
        vs_notesLabel = new javax.swing.JLabel();
        vs_cancelButton = new javax.swing.JButton();
        vs_lotnumLabel = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        vs_stocknumLabel = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("View Stock Details");
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel2.setText("Product Name");
        getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 60, 100, 20));

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel3.setText("Packing");
        getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 90, 50, 20));

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel4.setText("Receiving Date");
        getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 120, 90, 20));

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel5.setText("Balance");
        getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 150, 60, 20));

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel6.setText("RR No.");
        getContentPane().add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 180, 100, 20));

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel8.setText("Production Date");
        getContentPane().add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 240, 100, 20));

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel7.setText("Quedan");
        getContentPane().add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 210, -1, 20));

        jLabel9.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel9.setText("Expiry Date");
        getContentPane().add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 270, 80, 20));

        jLabel10.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel10.setText("Notes");
        getContentPane().add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 330, 38, 20));

        jLabel11.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel11.setText("Lot Number");
        getContentPane().add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 300, 70, 20));

        vs_productnameLabel.setText("Heng Bing Pieces and Stem Mushroom");
        getContentPane().add(vs_productnameLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 60, 210, 20));

        vs_packingLabel.setText("24 x 400 g.");
        getContentPane().add(vs_packingLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 90, 170, 20));

        vs_receivingdateLabel.setText("10-10-11");
        getContentPane().add(vs_receivingdateLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 120, 170, 20));

        vs_balanceLabel.setText("300");
        getContentPane().add(vs_balanceLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 150, 170, 20));

        vs_RRnumLabel.setText("001720");
        getContentPane().add(vs_RRnumLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 180, 170, 20));

        vs_quedanLabel.setText("554011");
        getContentPane().add(vs_quedanLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 210, 170, 20));

        vs_proddateLabel.setText("12-25-10");
        getContentPane().add(vs_proddateLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 240, 170, 20));

        vs_expdateLabel.setText("12-25-13");
        getContentPane().add(vs_expdateLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 270, 170, 20));
        getContentPane().add(vs_notesLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 330, 170, 20));

        vs_cancelButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/Button-Close-icon.png"))); // NOI18N
        vs_cancelButton.setText("Cancel");
        vs_cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vs_cancelButtonActionPerformed(evt);
            }
        });
        getContentPane().add(vs_cancelButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 380, 100, -1));

        vs_lotnumLabel.setText("305");
        getContentPane().add(vs_lotnumLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 300, 170, 20));

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel12.setText("Stock No.");
        getContentPane().add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 30, 100, 20));

        vs_stocknumLabel.setText("1002");
        getContentPane().add(vs_stocknumLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 30, 170, 20));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void vs_cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vs_cancelButtonActionPerformed
        // TODO add your handling code here:
        addorder.setEnabled(true);
        this.setVisible(false);
        this.dispose();
}//GEN-LAST:event_vs_cancelButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel vs_RRnumLabel;
    private javax.swing.JLabel vs_balanceLabel;
    private javax.swing.JButton vs_cancelButton;
    private javax.swing.JLabel vs_expdateLabel;
    private javax.swing.JLabel vs_lotnumLabel;
    private javax.swing.JLabel vs_notesLabel;
    private javax.swing.JLabel vs_packingLabel;
    private javax.swing.JLabel vs_proddateLabel;
    private javax.swing.JLabel vs_productnameLabel;
    private javax.swing.JLabel vs_quedanLabel;
    private javax.swing.JLabel vs_receivingdateLabel;
    private javax.swing.JLabel vs_stocknumLabel;
    // End of variables declaration//GEN-END:variables

}
